﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;

public partial class _Default : System.Web.UI.Page
{
    protected Book bookBll;
    static protected IList<BookInfo> bList;
    protected void Page_Load(object sender, EventArgs e)
    {
        bookBll = new Book();
        if (!Page.IsPostBack)
        {
            
            bList = bookBll.GetHotBooks();
            BookList.DataSource = bList;
            BookList.DataBind();
        }
    }

    protected void BookList_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Response.Redirect("~/ItemPage.aspx?ISBN=" + bList[e.Item.ItemIndex].ISBN);
    }
    protected void HotButton_Click(object sender, EventArgs e)
    {
        bList = bookBll.GetHotBooks();
        BookList.DataSource = bList;
        BookList.DataBind();
    }
    protected void NewButton_Click(object sender, EventArgs e)
    {
        bList = bookBll.GetNewBooks();
        BookList.DataSource = bList;
        BookList.DataBind();
    }
    protected void SearchButton_Click(object sender, EventArgs e)
    {
        if (SearchInput.Text == "")
        {
            Response.Write("<script>alert('请输入需要查找的关键字')</script>");
            return;
        }
        bList = bookBll.SearchBooks(SearchInput.Text);
        BookList.DataSource = bList;
        BookList.DataBind();
    }
}
